import globals from "globals";
import stylistic from "@stylistic/eslint-plugin";
import parserTs from "@typescript-eslint/parser";
import reactHooks from "eslint-plugin-react-hooks";
import tailwindcss from "eslint-plugin-tailwindcss";
import pluginPrettier from "eslint-plugin-prettier/recommended";

export default [
  {
    files: ["**/*.{js,mjs,ts,tsx}"],
    languageOptions: {
      globals: globals.browser,
      parser: parserTs,
      parserOptions: {
        ecmaFeatures: { jsx: true },
        ecmaVersion: "latest",
        project: "./tsconfig.json",
      },
    },
  },
  {
    /**
     * @see https://github.com/facebook/react/issues/28313
     * @see https://github.com/facebook/react/pull/28773
     */
    plugins: {
      "react-hooks": {
        rules: reactHooks.rules,
      },
    },
    rules: {
      "react-hooks/rules-of-hooks": "error",
      "react-hooks/exhaustive-deps": "warn",
    },
  },
  stylistic.configs["disable-legacy"],
  ...tailwindcss.configs["flat/recommended"],
  pluginPrettier,
  { ignores: ["dist", "node_modules"] },
];
